package airthmetic.exercise.arr;



public class _2960_统计已测试设备 {

    // 差分数组思想 O(n)
    public int countTestedDevices(int[] batteryPercentages) {
        int n = batteryPercentages.length;
        int count = 0;
        for(int i=0; i<n; i++){
            if(batteryPercentages[i] > count){
                count++;
            }
        }

        return count;
    }

    // 暴力破解 O(n^2)
    public int countTestedDevices2(int[] batteryPercentages) {
        int n = batteryPercentages.length;
        int count = 0;
        for(int i=0; i<n; i++){
            if(batteryPercentages[i] > count){
                count++;
            }
        }

        return count;
    }
}
